<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 从根目录下访问vue.js -->
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript">
        Vue.config.productionTip = false  //阻止 vue 在启动时生成生产提示。
    </script>
</head>

<body>
    <div id="app">
        <component :is="currentTab"></component>
        <button @click="changeTo1">切换到1</button>
        <button @click="changeTo2">切换到2</button>
    </div>
</body>

<script type="text/javascript">
    Vue.component('hhm1', {
        template: `
        <div>这是hhm1</div>
    `
    })
    Vue.component('hhm2', {
        template: `
        <div>这是hhm2</div>
    `
    })
    new Vue({
        el: "#app",
        data: {
            currentTab: "hhm1",
        },
        methods: {
            changeTo1(){
                this.currentTab="hhm1"
            },
            changeTo2(){
                this.currentTab="hhm2"
            }
        }
    })
</script>

</html>


